﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using JYStockAnalyser.Face;
using JYStockAnalyser.Model;
using JYStockAnalyser.ClientLib;


namespace JYStockAnalyser.Manager
{
    public partial class frmEditStock : Form
    {
        public frmEditStock(Stock stock)
        {
            InitializeComponent();
            this.stockEditor1.SetStock(stock);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (stockEditor1.Vali()) ;
            {
                Stock stock = this.stockEditor1.GetStock();
                StockManageFace face = new StockManageFace();
                try
                {
                    face.UpdateStock(stock);
                    Tool.ShowInformationBox("更新成功!");
                    this.DialogResult = DialogResult.Yes;
                    this.Close();
                }
                catch (PropertiesExistsException)
                {
                    Tool.ShowInformationBox("股票编号已存在!");
                }
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
